package com.sengled.cloud.biz.union.mgt.dao.sys;


import com.sengled.cloud.biz.union.mgt.common.PageUtil;
import com.sengled.cloud.biz.union.mgt.model.po.ShopAccount;
import com.sengled.cloud.biz.union.mgt.model.po.UserAcctShopAcct;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.security.access.method.P;

import java.util.List;

@Mapper
public interface UserAcctShopAcctDao {
    int deleteByPrimaryKey(Long id);

    int insert(UserAcctShopAcct record);

    int insertSelective(UserAcctShopAcct record);

    UserAcctShopAcct selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(UserAcctShopAcct record);

    int updateByPrimaryKey(UserAcctShopAcct record);

    @Select("select count(*) from user_acct_shop_acct where user_account_id = #{accountId} and shop_account_id = #{shopId}")
    int queryUserAcctShopAcctCount(@Param("shopId") Long shopId,@Param("accountId") Long accountId);

    @Select("select count(*) from user_acct_shop_acct where user_account_id = #{userAccountId}")
    int queryUserAcctShopAcctCountByUserKey(@Param("userAccountId") Long userAccountId);

    @Select("select sa.id as id,sa.account_code as accountCode,sa.account_pwd as accountPwd,sa.account_status as accountStatus" +
            ",sa.company_id as companyId,sa.shop_id as shopId,sa.shop_code as shopCode,sa.shop_name as shopName,sa.qr_code as qrCode,sa.create_date as createDate,sa.operator_id as operatorId,sa.seal_mark as sealMark" +
            ",sa.enable_mark as enableMark from user_acct_shop_acct uasa,shop_account sa where uasa.shop_account_id = sa.id and uasa.user_account_id = #{userAccountId} order by sa.create_date desc limit #{pageUtil.start},#{pageUtil.pageSize} ")
    List<ShopAccount> listShopAccount(@Param("userAccountId") Long userAccountId,@Param("pageUtil") PageUtil pageUtil);


}